package com.md.drcs.dicom.service.impl;

import com.md.drcs.dicom.dao.DiskDao;
import com.md.drcs.dicom.entity.DiskEntity;
import com.md.drcs.dicom.service.DiskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class DiskServiceImpl implements DiskService {

    @Autowired
    private DiskDao diskDao;

    @Override
    public DiskEntity getUsingDisk() {
        return diskDao.getCurrentActivedDisk();
    }

    @Override
    public void switchDisk(String diskCode) {
        diskDao.stopUsingDisk(); // 停止现使用等磁盘
        diskDao.activeDisk(diskCode); // 激活新磁盘
    }

    @Override
    public void updateDiskUsedSpace(String diskCode, Integer usedSpace) {
        diskDao.updateDiskUsedSpace(diskCode, usedSpace);
    }

}
